﻿using CleanArchitecture.Core.Interfaces;
using CleanArchitecture.Infrastructure.Entities.AdminUsers;
using CleanArchitecture.Infrastructure.Models.AdminUsers;
using System.Collections.Generic;

namespace CleanArchitecture.Infrastructure.Interfaces.AdminUsers
{
    public partial interface IAdminUserService
    {
        /// <summary>
        /// 获取指定用户所分配的用户角色
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        IList<AdminRole> GetAdminUserRolesByUserId(int userId);
        /// <summary>
        /// Update AdminUser Entity 
        /// </summary>
        /// <param name="adminuser"></param>
        void UpdateAdminUser(AdminUser adminuser);
        void InsertAdminUser(AdminUser adminuser);

        AdminUser GetAdminUserById(int id);
        /// <summary>
        /// Get Paged AdminUsers
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        IViewPagedList<AdminUser> GetAdminUsers(int pageIndex = 0, int pageSize = int.MaxValue);
        /// <summary>
        /// Get adminuser by email
        /// </summary>
        /// <param name="email">Email</param>
        /// <returns>Customer</returns>
        AdminUser GetAdminUserByEmail(string email);

        /// <summary>
        /// Get adminuser by Mobile
        /// </summary>
        /// <param name="mobile">MobileNum</param>
        /// <returns>Customer</returns>
        AdminUser GetAdminUserByMobile(string mobile);

        /// <summary>
        /// Get adminuser by Loginname
        /// </summary>
        /// <param name="">loginname</param>
        /// <returns>Customer</returns>
        AdminUser GetAdminUserByLoginname(string loginname);

        /// <summary>
        /// Get current adminuser password
        /// </summary>
        /// <param name="userId">AdminUser identifier</param>
        /// <returns>AdminUser password</returns>
        AdminUserPassword GetCurrentPassword(int userId);

        /// <summary>
        /// Insert a user password
        /// </summary>
        /// <param name="customerPassword">Customer password</param>
        void InsertAdminUserPassword(AdminUserPassword Password);

        /// <summary>
        /// Update a user password
        /// </summary>
        /// <param name="customerPassword">Customer password</param>
        void UpdateAdminUserPassword(AdminUserPassword Password);

        /// <summary>
        /// Check whether customer password is expired 
        /// </summary>
        /// <param name="customer">Customer</param>
        /// <returns>True if password is expired; otherwise false</returns>
        bool PasswordIsExpired(AdminUser user);
        IList<AdminRole> GetAdminRolesAll();
        /// <summary>
        /// 尽量减少使用GetAdminRoleAll，避免NullReference Exception
        /// </summary>
        /// <returns></returns>
        IList<AdminRoleModel> GetAdminRoleModelsAll();

        AdminRole GetAdminRoleById(int id);
        /// <summary>
        /// Update AdminRole Entity
        /// </summary>
        /// <param name="role"></param>
        /// <param name="excludeProperties"></param>
        void UpdateAdminRole(AdminRole role, IList<string> excludeProperties = null);
        /// <summary>
        /// 检查用户-角色对应表，如果被删除用户角色有对应的用户只关联唯一用户角色，则不允许删除角色
        /// </summary>
        /// <param name="roleId"></param>
        /// <returns></returns>
        bool CheckAdminRoleBeforeDelete(int roleId);
        /// <summary>
        /// Insert AdminRole
        /// </summary>
        /// <param name="role"></param>
        void InsertAdminRole(AdminRole role);
    }
}
